<?php
/*
 * common.php
 * name:xiaojia
 * email:iatt@qq.com
 * qq:273142650
 * time:2011.10.28 11:21
*/
	class common
	{
		
		static function webos_data ()
		{
			
			$webosdata = Jdb::getRs("SELECT * FROM " . PRE . "basicdata");
			
			while ($rs = mysql_fetch_array($webosdata)) {
				
				$ret[$rs['dataIndex']] = $rs['dataValue'];
				
			}
			
			return $ret;
			
		}
		
		static function webos_basic ()
		{
			
			$webosdata = Jdb::getRs("SELECT * FROM " . PRE . "webbasic");
			
			while ($rs = mysql_fetch_array($webosdata)) {
				
				$ret[$rs['dataIndex']] = $rs['dataValue'];
				
			}
			
			return $ret;
			
		}
		
		static function checkformhash()
		{
			
			!JAdmin_core::HASH(Jpublic::get('formhash')) && exit();
			
		}
		
		static function getDate () {
			
			return date('Y/m/d H:i:s');
			
		}
		
		static function add0 ($num) {
			
			for ($i = strlen($num); $i < 6; $i++) {
				
				$num = '0' . $num;
				
			}
			
			return $num;
			
		}
		
		static function replaceUrl ($url) {
			
			return preg_replace('/&{1}/i', '$1&amp;$2', $url);
			
		}
		
		static function getAttr($group) {
			
			return Jdb::getRs("SELECT * FROM `".PRE."attribute` WHERE attrGroup = '$group' ORDER BY attrSort DESC");
			
		}
		
		static function log ($operation, $text = '') {
			
			global $USER;
			
			$addtime = date('Y-m-d H:i:s');
			
			$array = array(
			
				'userID' => $USER['uid'],
				
				'userName' => $USER['username'],
				
				'userGroupName' => $USER['webos_group_file'],
				
				'operationPage' => $_SERVER['REQUEST_URI'],
				
				'operationType' => $operation,
				
				'operationText' =>  $text,
				
				'operationIP' => $_SERVER['REMOTE_ADDR'],
				
				'operationDatetime' => $addtime
				
			);
			
			Jdb::insert(PRE.'log', $array);
			
		}
		
	}
?>